<template>
  <div style="width: 100%;height: 100%">
    <div ref="container" style="width: 100%;height: 100%"></div>
  </div>
</template>

<script>
import Charts from "@jiaminghi/charts";
import {currentGET} from "api";

export default {
  data() {
    return {
      option1: {
        legend: {
          data: ['总销售额', '合同额']
        },
        xAxis: {
          name: '年月',
          data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
          axisLabel: {
            formatter: '{value}',
            style: {
              fill: '#1ed3e5',
            }
          },
        },
        yAxis: {
          name: '销售额',
          data: 'value',
          axisLabel: {
            formatter: '{value}',
            style: {
              fill: '#1ed3e5',
            }
          },
        },
        series: [
          {
            name: '总销售额',
            data: [1200, 2230, 1900, 2100, 3500, 4200, 3985],
            type: 'line',
            stack: 'a',
            fill: {
              show: true
            }
          },
          {
            name: '合同额',
            data: [1200, 2230, 1900, 2100, 3500, 4200, 3985],
            type: 'line',
            stack: 'a',
            smooth: true
          }
        ]
      }
    }
  },
  methods: {
    async init() {
      await currentGET('big4').then(res => {
        this.option1.xAxis.data = res.data.dateList
        this.option1.series[0].data = res.data.numList
        this.option1.series[1].data = res.data.numList2
      })
      const myChart = new Charts(this.$refs.container)
      myChart.setOption(this.option1)
    }
  },
  mounted() {
    this.init()
  }
}
</script>

<style>

</style>
